/*
 *  Copyright 2010 UPF Telecos 4th group G.
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *  under the License.
 */

package edu.upf.editor;

import java.io.File;
import javax.swing.filechooser.FileFilter;

/**
 * This class provides different filters to distinguish image formats
 * @author beto
 */
public class ImageFilters {

    private JPGFilter jpgFilter;
    private PNGFilter pngFilter;
    private GIFFilter gifFilter;

    public ImageFilters(){
        jpgFilter = new JPGFilter();
        pngFilter = new PNGFilter();
        gifFilter = new GIFFilter();
    }

    class JPGFilter extends javax.swing.filechooser.FileFilter {

        @Override
        public boolean accept(File f) {
            return f.isDirectory() || f.getName().toLowerCase().endsWith(".jpg");
        }

        @Override
        public String getDescription() {
            return "JPG files";
        }
    }

    class PNGFilter extends javax.swing.filechooser.FileFilter {

        @Override
        public boolean accept(File f) {
            return f.isDirectory() || f.getName().toLowerCase().endsWith(".png");
        }

        @Override
        public String getDescription() {
            return "PNG files";
        }
    }

    class GIFFilter extends javax.swing.filechooser.FileFilter {

        @Override
        public boolean accept(File f) {
            return f.isDirectory() || f.getName().toLowerCase().endsWith(".gif");
        }

        @Override
        public String getDescription() {
            return "GIF files";
        }
    }

    public FileFilter getJPGFilter(){
        return jpgFilter;
    }

    public FileFilter getPNGFilter(){
        return pngFilter;
    }

    public FileFilter getGIFFilter(){
        return gifFilter;
    }  
}
